var chargingApp = angular.module('chargingApp', ['chargingApp.chargingService']);


var chargePortArray = {};
chargePortArray['1'] = 'A:';
chargePortArray['2'] = 'B:';
chargePortArray['3'] = 'C:';

chargingApp.filter('getValueInStaticFilter', function() {
  return function(input, staticArrayName) {
    var value = eval(staticArrayName + "[input]");
    if (!!value) {
      return value;
    }
    return "";
  };
});
chargingApp.controller('chargingController', function($scope, chargingService, $timeout, $filter, $interval) {
  $scope.initView = function() {
    chargingService.getChargerStatusByStationId().then(function(data) {
      var list = data.list;
      $scope.list = list.slice(0,8);
      $scope.list_1 = list.slice(8,16);
      $scope.list_2 = list.slice(16,24);
      $scope.list_3 = list.slice(24,32);
      $scope.list_4 = list.slice(32,38);
      // $scope.current1 = Math.ceil(Math.random()*(80-72)+72);
      // $scope.current2 = Math.ceil(Math.random()*(80-72)+72);
      // $scope.current3 = Math.ceil(Math.random()*(80-72)+72);
      // $scope.current4 = Math.ceil(Math.random()*(80-72)+72);
      // $scope.current5 = Math.ceil(Math.random()*(80-72)+72);
      // $scope.current6 = Math.ceil(Math.random()*(80-72)+72);
      // $scope.current7 = Math.ceil(Math.random()*(80-72)+72);
    });
  };
  $scope.getWeatherByCityId = function(){
    chargingService.getWeatherByCityId().then(function(data){
      $scope.weatherList = data.pojo;
    })
  };
  $scope.getWeatherByCityId();
  $scope.initView();
  // var count = 0;
  // $interval(function() {
  //   count++;
  //   if (count == 1 || count % 3 == 0) {
  //     $scope.initView();
  //   }
  // }, 20000);
  // $interval(function(){
  //   $scope.initView()
  // },10000);
});